from django.db.models.sql.query import Query
from books.models import *
from django.db.models.expressions import Col


def run():
    query = Query(Books)
    query.default_cols = False
    book_name = models.CharField(
        max_length=30, verbose_name='图书名', db_column='book_name')
    book_name.set_attributes_from_name('book_name')
    query.select = (Col('books', book_name), )
    print(query.sql_with_params())
    print(query.get_meta().concrete_fields)
    columns = query.get_compiler('default').get_default_columns()
    print(columns)
